package com.bigflexlib.core.os.call
{
	
	
	import com.bigflexlib.core.os.thread.Thread;
	import com.bigflexlib.utils.StateHolder;
	


	public class BaseCall extends StateHolder implements ICall
	{
		

		
		
		private var _thread:Thread;
		public function get thread( ):Thread
		{
			return _thread;
		}
		
		
		private var _func:Function;
		public function get func( ):Function
		{
			return _func;
		}
		
		
		private var _args:Array;
		public function get args( ):Array
		{
			return _args;
		}
		
		
		
		public function get remoteTarget( ):*
		{
			return null;
		}
		
		
		public function get isSync( ):Boolean
		{
			return false;
		}
		
		
		
		
		public function BaseCall( thread:Thread, func:Function, args:Array = null )
		{
			
			super( CallState.PENDING );
			
			_thread = thread;
			_func = func;
			_args = args ? args : [ ];
		}






		public function execute( ):void
		{
			
			setState( CallState.EXECUTING );
		
//			try {
				func.apply( null, args );	
//			} catch ( e:Error ){
//			}
			
			if ( isSync )
				setState( CallState.COMPLETE );
		}


	}
	
}